"use client";

import type * as React from "react";

import { AIChatPlugin } from "@platejs/ai/react";
import { useEditorPlugin } from "platejs/react";

import { ToolbarButton } from "./toolbar";

export function AIToolbarButton(
  props: React.ComponentProps&lt;typeof ToolbarButton&gt;,
) {
  const { api } = useEditorPlugin(AIChatPlugin);

  return (
    &lt;ToolbarButton
      {...props}
      onClick={() =&gt; {
        api.aiChat.show();
      }}
      onMouseDown={(e) =&gt; {
        e.preventDefault();
      }}
    /&gt;
  );
}
